#include <vector>
using namespace std;
/*
 * @lc app=leetcode.cn id=118 lang=cpp
 *
 * [118] 杨辉三角
 */

// @lc code=start
class Solution {
public:
    vector<vector<int>> generate(int numRows) {
        vector<vector<int>> res;
        for (int i = 0; i < numRows; i++) {
            if (i == 0) {
                res.push_back({1});
                continue;
            }
            vector<int> temp = {1};
            for (int l = 0, r = 1; r < res[i - 1].size(); l++, r++) {
                temp.push_back(res[i - 1][l] + res[i - 1][r]);
            }
            temp.push_back(1);
            res.push_back(temp);
        }
        return res;
    }
};
// @lc code=end

